From 127ca6cf1ad66548fe88f39699f6479be8b37fe7 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 4 Nov 2025 15:41:49 +0100 Subject: [PATCH] Drop restarting capapbility Part-of: --- js/ui/layout.js | 7 +- js/ui/main.js | 38 ------- js/ui/runDialog.js | 15 --- man/gnome-shell.rst | 4 - src/gnome-shell-test-tool.in | 17 +--- src/main.c | 8 +- src/shell-global.c | 185 ----------------------------------- src/shell-global.h | 2 - 8 files changed, 5 insertions(+), 271 deletions(-) diff --git a/js/ui/layout.js b/js/ui/layout.js index fa4c5b057..a13ba6205 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -729,9 +729,7 @@ export const LayoutManager = GObject.registerClass({ // windows restore to the right size. this._updateRegions(); - if (Meta.is_restart()) { - // On restart, we don't do an animation. - } else if (Main.sessionMode.isGreeter) { + if (Main.sessionMode.isGreeter) { this.panelBox.translation_y = -this.panelBox.height; } else { this.keyboardBox.hide(); @@ -768,9 +766,6 @@ export const LayoutManager = GObject.registerClass({ } async _startupAnimation() { - if (Meta.is_restart()) - return; - if (Main.sessionMode.isGreeter) await this._startupAnimationGreeter(); else diff --git a/js/ui/main.js b/js/ui/main.js index c8cf0c9bb..c911ab217 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -1,4 +1,3 @@ -import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; import GioUnix from 'gi://GioUnix'; import GLib from 'gi://GLib'; @@ -21,7 +20,6 @@ import * as InputMethod from '../misc/inputMethod.js'; import * as Introspect from '../misc/introspect.js'; import * as Keyboard from './keyboard.js'; import * as MessageTray from './messageTray.js'; -import * as ModalDialog from './modalDialog.js'; import * as OsdWindow from './osdWindow.js'; import * as OsdMonitorLabeler from './osdMonitorLabeler.js'; import * as Overview from './overview.js'; @@ -288,16 +286,6 @@ async function _initializeUI() { locatePointer.show(); }); - global.display.connect('show-restart-message', (display, message) => { - showRestartMessage(message); - return true; - }); - - global.display.connect('restart', () => { - global.reexec_self(); - return true; - }); - global.display.connect('gl-video-memory-purged', loadTheme); global.context.connect('notify::unsafe-mode', () => { @@ -1019,32 +1007,6 @@ export function queueDeferredWork(workId) { } } -const RestartMessage = GObject.registerClass( -class RestartMessage extends ModalDialog.ModalDialog { - _init(message) { - super._init({ - shellReactive: true, - styleClass: 'restart-message', - shouldFadeIn: false, - destroyOnClose: true, - }); - - const label = new St.Label({ - text: message, - x_align: Clutter.ActorAlign.CENTER, - y_align: Clutter.ActorAlign.CENTER, - }); - - this.contentLayout.add_child(label); - this.buttonLayout.hide(); - } -}); - -function showRestartMessage(message) { - const restartMessage = new RestartMessage(message); - restartMessage.open(); -} - class AnimationsSettings { constructor() { this._animationsEnabled = true; diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index 9c347ed3c..2d6c71704 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -2,7 +2,6 @@ import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; -import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; @@ -40,11 +39,6 @@ class RunDialog extends ModalDialog.ModalDialog { this._internalCommands = { 'lg': () => Main.createLookingGlass().open(), - 'r': this._restart.bind(this), - - // Developer brain backwards compatibility - 'restart': this._restart.bind(this), - 'debugexit': () => global.context.terminate(), // rt is short for "reload theme" @@ -251,15 +245,6 @@ class RunDialog extends ModalDialog.ModalDialog { this._descriptionLabel.set_text(message); } - _restart() { - if (Meta.is_wayland_compositor()) { - this._showError(_('Restart is not available on Wayland')); - return; - } - this._shouldFadeOut = false; - this.close(); - Meta.restart(_('Restarting…'), global.context); - } open() { this._history.lastItem(); diff --git a/man/gnome-shell.rst b/man/gnome-shell.rst index bd89f9f4f..c577e91aa 100644 --- a/man/gnome-shell.rst +++ b/man/gnome-shell.rst @@ -43,10 +43,6 @@ OPTIONS Wayland display name to use -``-r``, ``--replace`` - - Replace the running window manager - ``--mode=MODE`` Use a specific mode, e.g. "gdm" for login screen diff --git a/src/gnome-shell-test-tool.in b/src/gnome-shell-test-tool.in index 536409348..b3197878b 100755 --- a/src/gnome-shell-test-tool.in +++ b/src/gnome-shell-test-tool.in @@ -49,9 +49,6 @@ def start_shell(wrap=None, perf_output=None): args.append('--force-animations') - if options.replace: - args.append('--replace') - if options.wayland or options.nested or options.headless: args.append('--wayland') if options.nested: @@ -81,13 +78,6 @@ def run_shell(wrap=None, perf_output=None): shell.wait() return shell.returncode == 0 -def restore_shell(): - pid = os.fork() - if (pid == 0): - os.execlp("gnome-shell", "gnome-shell", "--replace") - else: - sys.exit(0) - def upload_performance_report(report_text): try: config_home = os.environ['XDG_CONFIG_HOME'] @@ -309,8 +299,6 @@ parser.add_argument("--version", action="version", parser.add_argument("--wrap") -parser.add_argument("-r", "--replace", action="store_true", - help="Replace the running window manager") parser.add_argument("-w", "--wayland", action="store_true", help="Run as a Wayland compositor") parser.add_argument("-n", "--nested", action="store_true", @@ -331,8 +319,5 @@ if options.script == 'hwtest': options.extra_filter.append('Gedit') normal_exit = run_performance_test(wrap=options.wrap) -if normal_exit: - if not options.hwtest and options.replace: - restore_shell() -else: +if not normal_exit: sys.exit(1) diff --git a/src/main.c b/src/main.c index 7feef04b7..2cef065f9 100644 --- a/src/main.c +++ b/src/main.c @@ -82,7 +82,7 @@ shell_dbus_acquire_name (GDBusProxy *bus, } static void -shell_dbus_init (gboolean replace) +shell_dbus_init () { GDBusConnection *session; GDBusProxy *bus; @@ -113,8 +113,6 @@ shell_dbus_init (gboolean replace) } request_name_flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT; - if (replace) - request_name_flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE; shell_dbus_acquire_name (bus, request_name_flags, @@ -123,7 +121,7 @@ shell_dbus_init (gboolean replace) if (!(request_name_result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER || request_name_result == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)) { - g_printerr (SHELL_DBUS_SERVICE " already exists on bus and --replace not specified\n"); + g_printerr (SHELL_DBUS_SERVICE " already exists on bus\n"); exit (1); } @@ -668,7 +666,7 @@ main (int argc, char **argv) shell_init_debug (g_getenv ("SHELL_DEBUG")); - shell_dbus_init (meta_context_is_replacing (context)); + shell_dbus_init (); shell_a11y_init (); shell_perf_log_init (); shell_introspection_init (); diff --git a/src/shell-global.c b/src/shell-global.c index f4c69e0d3..95f4f3679 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -1067,191 +1067,6 @@ _shell_global_get_gjs_context (ShellGlobal *global) * http://bugzilla.gnome.org/show_bug.cgi?id=357585 */ -static int -set_cloexec (void *data, gint fd) -{ - if (fd >= GPOINTER_TO_INT (data)) - fcntl (fd, F_SETFD, FD_CLOEXEC); - - return 0; -} - -#ifndef HAVE_FDWALK -static int -fdwalk (int (*cb)(void *data, int fd), void *data) -{ - gint open_max; - gint fd; - gint res = 0; - -#ifdef HAVE_SYS_RESOURCE_H - struct rlimit rl; -#endif - -#ifdef __linux__ - DIR *d; - - if ((d = opendir("/proc/self/fd"))) { - struct dirent *de; - - while ((de = readdir(d))) { - glong l; - gchar *e = NULL; - - if (de->d_name[0] == '.') - continue; - - errno = 0; - l = strtol(de->d_name, &e, 10); - if (errno != 0 || !e || *e) - continue; - - fd = (gint) l; - - if ((glong) fd != l) - continue; - - if (fd == dirfd(d)) - continue; - - if ((res = cb (data, fd)) != 0) - break; - } - - closedir(d); - return res; - } - - /* If /proc is not mounted or not accessible we fall back to the old - * rlimit trick */ - -#endif - -#ifdef HAVE_SYS_RESOURCE_H - if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY) - open_max = rl.rlim_max; - else -#endif - open_max = sysconf (_SC_OPEN_MAX); - - for (fd = 0; fd < open_max; fd++) - if ((res = cb (data, fd)) != 0) - break; - - return res; -} -#endif - -static void -pre_exec_close_fds(void) -{ - fdwalk (set_cloexec, GINT_TO_POINTER(3)); -} - -/** - * shell_global_reexec_self: - * @global: A #ShellGlobal - * - * Restart the current process. Only intended for development purposes. - */ -void -shell_global_reexec_self (ShellGlobal *global) -{ - GPtrArray *arr; - gsize len; - MetaContext *meta_context; - -#if defined __linux__ || defined __sun - char *buf; - char *buf_p; - char *buf_end; - g_autoptr (GError) error = NULL; - - if (!g_file_get_contents ("/proc/self/cmdline", &buf, &len, &error)) - { - g_warning ("failed to get /proc/self/cmdline: %s", error->message); - return; - } - - buf_end = buf+len; - arr = g_ptr_array_new (); - /* The cmdline file is NUL-separated */ - for (buf_p = buf; buf_p < buf_end; buf_p = buf_p + strlen (buf_p) + 1) - g_ptr_array_add (arr, buf_p); - - g_ptr_array_add (arr, NULL); -#elif defined __OpenBSD__ - gchar **args, **args_p; - gint mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; - - if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1) - return; - - args = g_malloc0 (len); - - if (sysctl (mib, G_N_ELEMENTS (mib), args, &len, NULL, 0) == -1) { - g_warning ("failed to get command line args: %d", errno); - g_free (args); - return; - } - - arr = g_ptr_array_new (); - for (args_p = args; *args_p != NULL; args_p++) { - g_ptr_array_add (arr, *args_p); - } - - g_ptr_array_add (arr, NULL); -#elif defined __FreeBSD__ - char *buf; - char *buf_p; - char *buf_end; - gint mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, getpid() }; - - if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1) - return; - - buf = g_malloc0 (len); - - if (sysctl (mib, G_N_ELEMENTS (mib), buf, &len, NULL, 0) == -1) { - g_warning ("failed to get command line args: %d", errno); - g_free (buf); - return; - } - - buf_end = buf+len; - arr = g_ptr_array_new (); - /* The value returned by sysctl is NUL-separated */ - for (buf_p = buf; buf_p < buf_end; buf_p = buf_p + strlen (buf_p) + 1) - g_ptr_array_add (arr, buf_p); - - g_ptr_array_add (arr, NULL); -#else - return; -#endif - - /* Close all file descriptors other than stdin/stdout/stderr, otherwise - * they will leak and stay open after the exec. In particular, this is - * important for file descriptors that represent mapped graphics buffer - * objects. - */ - pre_exec_close_fds (); - - meta_context = shell_global_get_context (global); - meta_context_restore_rlimit_nofile (meta_context, NULL); - - meta_display_close (shell_global_get_display (global), - shell_global_get_current_time (global)); - - execvp (arr->pdata[0], (char**)arr->pdata); - g_warning ("failed to reexec: %s", g_strerror (errno)); - g_ptr_array_free (arr, TRUE); -#if defined __linux__ || defined __FreeBSD__ - g_free (buf); -#elif defined __OpenBSD__ - g_free (args); -#endif -} - /** * shell_global_notify_error: * @global: a #ShellGlobal diff --git a/src/shell-global.h b/src/shell-global.h index 4894d8b4e..3bbe3e0ab 100644 --- a/src/shell-global.h +++ b/src/shell-global.h @@ -90,8 +90,6 @@ void shell_global_notify_error (ShellGlobal *global, const char *msg, const char *details); -void shell_global_reexec_self (ShellGlobal *global); - const char * shell_global_get_session_mode (ShellGlobal *global); void shell_global_set_runtime_state (ShellGlobal *global, -- 2.39.5